<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Emp_Cert extends Page
{
       public $hiddenEmp = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $chkComplete = null;
       public $memoComments = null;
       public $cmbdesc = null;
       public $dpLicenseRenew = null;
       public $Label2 = null;
       public $Label1 = null;
       public $JTSiteTheme1 = null;
       public $Label3 = null;
       public $Image1 = null;
       function btnCancelClick($sender, $params)
       {
       redirect('emp_certification_list.php?emp='.$this->hiddenEmp->getValue());


       }

       function Emp_CertCreate($sender, $params)
       {
       $emp = $_GET['emp'];
       $this->hiddenEmp->setValue($emp);

       $this->cmbdesc->Clear();
       $result_desc = mysql_query("select * from lookup_personnel_tbl where category='renewals/certifications'");

        while($row_desc = mysql_fetch_array($result_desc))
        {
            $this->cmbdesc->AddItem($row_desc['value'], null, $row_desc['value']);
        }

        $this->dpLicenseRenew->Date='';
        $this->memoComments->Text='';
        $this->chkComplete->Checked=false;


       }

       function btnSubmitClick($sender, $params)
       {
        if($this->chkComplete->Checked==true)
       {
       $complete = '1';
       }
       else
       {
       $complete = '0';
       }


       $result = mysql_query("insert into emp_certification_tbl (company_id,
       emp_id,
       cert_date,
       description,
       comments,
       completed)

       values ('".$_SESSION['company_id']."',
       '".$this->hiddenEmp->getValue()."',
       '".$this->dpLicenseRenew->Date."',
       '".$this->cmbdesc->getItemIndex()."',
       '".$this->memoComments->Text."',
       '".$complete."')");

       redirect('emp_certification_list.php?emp='.$this->hiddenEmp->getValue());
       }

}

global $application;

global $Emp_Cert;

//Creates the form
$Emp_Cert=new Emp_Cert($application);

//Read from resource file
$Emp_Cert->loadResource(__FILE__);

//Shows the form
$Emp_Cert->show();

?>